﻿<%@ Page Title="Manage ConnectionStrings" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ManageConnectingStrings.aspx.cs" Inherits="NIntegrate.Configuration.UI.ManageConnectingStrings" MaintainScrollPositionOnPostback="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Manage ConnectionStrings</h2>
    <div class="bottomhyperlink"><img alt="Add new connectionstring" src="Images/plus.gif" /><asp:LinkButton 
            ID="btnShowAddNewPanel" runat="server" Text="Add new connectionstring" 
            onclick="btnShowAddNewPanel_Click"></asp:LinkButton></div>
    <br />
    <asp:GridView CssClass="gridview"
        ID="gvConnectionStrings" runat="server" 
        DataSourceID="dsConnectionStrings"
        DataKeyNames="Name,Environment_id"
        AllowSorting="true"
        AutoGenerateDeleteButton="true"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true" onrowcommand="gvConnectionStrings_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                <ItemTemplate>
                    <%#Eval("Name") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbName" runat="server" MaxLength="100" Text='<%#Bind("Name") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbNameRequired" runat="server"
                        ControlToValidate="tbName" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Environment" SortExpression="Environment_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlEnvironments" runat="server" SelectedValue='<%# Bind("Environment_id") %>' DataSourceID="dsEnvironments" DataTextField="Name" DataValueField="Environment_id" Enabled="false"></asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlEnvironments" runat="server" SelectedValue='<%# Bind("Environment_id") %>' DataSourceID="dsEnvironments" DataTextField="Name" DataValueField="Environment_id"></asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>            
            <asp:TemplateField HeaderText="Value" SortExpression="Value">
                <ItemTemplate>
                    <%#Eval("Value")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbValue" runat="server" Text='<%#Bind("Value") %>' Width="400px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbValueRequired" runat="server"
                        ControlToValidate="tbValue" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Provider" SortExpression="ProviderName">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlProviders" runat="server" SelectedValue='<%# Bind("ProviderName") %>' Enabled="false">
                        <asp:ListItem Text="SqlClient" Value="System.Data.SqlClient"></asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlProviders" runat="server" SelectedValue='<%# Bind("ProviderName") %>'>
                        <asp:ListItem Text="SqlClient" Value="System.Data.SqlClient"></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>                        
        </Columns>
        <SelectedRowStyle BackColor="LightYellow" />
    </asp:GridView>
    <asp:Panel ID="panelBottom" runat="server" CssClass="panelBottom">
        <asp:DetailsView ID="dvAddConnectionString" runat="server" Visible="false"
            DataSourceID="dsConnectionStrings" DefaultMode="Insert"
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true"
            CssClass="detailstable" onitemcommand="dvAddConnectionString_ItemCommand" 
            oniteminserted="dvAddConnectionString_ItemInserted">
            <Fields>
                <asp:TemplateField HeaderText="Name">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbName" runat="server" MaxLength="100" Text='<%#Bind("Name") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbNameRequired" runat="server"
                            ControlToValidate="tbName" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Environment">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlEnvironments" runat="server" SelectedValue='<%# Bind("Environment_id") %>' DataSourceID="dsEnvironments" DataTextField="Name" DataValueField="Environment_id"></asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>            
                <asp:TemplateField HeaderText="Value">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbValue" runat="server" Text='<%#Bind("Value") %>' Width="400px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbValueRequired" runat="server"
                            ControlToValidate="tbValue" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Provider">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlProviders" runat="server" SelectedValue='<%# Bind("ProviderName") %>'>
                            <asp:ListItem Text="SqlClient" Value="System.Data.SqlClient"></asp:ListItem>
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>              
            </Fields>
        </asp:DetailsView>
    </asp:Panel>
    <ni:QueryDataSource ID="dsEnvironments" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsConnectionStrings" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
</asp:Content>
